package cn.tedu.springbootdemo.controller;

import cn.tedu.springbootdemo.mapper.UserMapper;
import cn.tedu.springbootdemo.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class UserController {

    @Autowired
    UserMapper userMapper;


    @PostMapping("handle_reg.do")
    @ResponseBody
    public String doHandleReg(User user) {
        try {
            Integer rows = userMapper.addUser(user);
            System.out.printf(String.valueOf(rows));
            if (rows == 1) {
                return "注册成功";
            } else {
                return "注册失败";
            }

        } catch (Exception e) {
            e.printStackTrace();
            return "注册失败" + e;
        }

    }
}
